/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 测试;

import 解析.Matcher;
import 解析.Pattern;

/**
 *
 * @author yanxi
 */
public class 使用例子 {
    public static void main(String[] args){
         // 要验证的字符串 
        String str = "service@xsoftlab.net";

        // 邮箱验证规则 
        String regEx = "[a-zA-Z_]{1,}[0-9]{0,}@(([a-zA-z0-9]-*){1,}\\.){1,3}[a-zA-z\\-]{1,}";

        // 编译正则表达式 
        Pattern pattern = Pattern.compile(regEx); 
        // 忽略大小写的写法 
        // Pattern pat = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);

        Matcher matcher = pattern.matcher(str);

        // 字符串是否与正则表达式相匹配 
        boolean rs = matcher.matches();

        System.out.println(rs);
    }
}
